package com.hy.controller;

import com.hy.Result.ResponseResult;
import com.hy.utils.QueryParam;
import com.hy.pojo.Articles;
import com.hy.service.ArticlesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/articles")
public class ArticleController {

    @Autowired
    private ArticlesService articlesService;
    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody QueryParam queryParam){
        return articlesService.findAll(queryParam);
    }




    @PostMapping("/save")
    public boolean save(@RequestBody Articles articles){
        articles.setIsPublic("未公开");
        articles.setReviewStatus("未审核");
        return articlesService.save(articles);
    }
    @PostMapping("/update")
    public boolean update(@RequestBody Articles articles){
        return articlesService.updateById(articles);
    }
    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Integer id){
        return articlesService.removeById(id);
    }
}
